// 2025/3/29
// mari和shiny

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    char ch;
    long long s = 0, sh = 0, shy = 0;
    while(cin >> ch)
    {
        if(ch == 's') s += 1;
        else if(ch == 'h') sh += s;
        else if(ch == 'y') shy += sh;
    }
    cout << shy << endl;
}
// 64 位输出请用 printf("%lld")